﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;

namespace Milkify.ComponentModel
{
    public class DateBuilderExtension : MarkupExtension
    {
        public DateTime ReferenceDateTime { get; private set; }
        public int YearOffset { get; set; }
        public int MonthOffset { get; set; }
        public int DayOffset { get; set; }
        public int HourOffset { get; set; }
        public int MinuteOffset { get; set; }

        public DateBuilderExtension()
        {
            ReferenceDateTime = DateTime.Now;
        }

        public DateBuilderExtension(DateTime reference)
        {
            ReferenceDateTime = reference;
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            TimeSpan offset = new TimeSpan(DayOffset, HourOffset, MinuteOffset, 0);
            DateTime date = ReferenceDateTime + offset;
            date = date.AddYears(YearOffset).AddMonths(MonthOffset);
            return date.DayOfWeek.ToString();
        }
    }
}
